<?php
namespace app\admin\controller;

use app\admin\controller\Base;
use \think\Request;
use think\facade\View;
use app\common\model\CouponReceive as CouponReceiveModel;
use app\common\model\GoodsList;
use app\common\model\GoodsCate;
use app\common\model\GoodsSku;
use app\common\model\GoodsYong;
use app\common\model\Store;
use app\common\model\User;

class CouponReceive extends Base{
	/**
	 * 优惠券列表
	 */
	public function index(Request $request){
		$keyword=trim(input('get.keyword'));
 		$status=trim(input('get.status'));
 		$whe = [];
		if(!empty($keyword)){
			$whe[]=['title','like','%'.$keyword.'%'];
		
		}
		
		if(!empty($status)){
			$whe[]=['status','=',$status-1];
		}
		$field = "*";
		$order = "addtime desc";
		$data = CouponReceiveModel::getList($whe,$field,$order,$this->page);
		foreach($data['list'] as $key=>$val){
		   $user_info = User::getInfo(['id'=>$val['user_id']]); 
		   $data['list'][$key]['nickname'] = $user_info['nickname'];
		}
		View::assign('list',$data['list']);
		View::assign('count',$data['count']);
		View::assign('page',$data['page']);
		return View::fetch("CouponReceive/index");
	
	}

}
